package com.aos;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.Socket;

public class Listener extends Thread
{
	private Socket listenerSocket;
	private BufferedReader listenerStreamReader;
	
	public Listener(Socket socket, BufferedReader br)
	{
		this.listenerSocket = socket;
		this.listenerStreamReader = br;
	}
	public void run()
	{
		//System.out.println("Listening...........");
		while(true)
		{
			try 
			{
				while(!listenerStreamReader.ready())
				{
					
				}
				//System.out.println("Message Received.");
				
				String receiveMsg = listenerStreamReader.readLine();
				
				new Thread(new Receiver(receiveMsg)).start();
				
				//System.out.println(receiveMsg);
				//buildSpanningTree(receiveMsg);
								
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public Socket getListenerSocket() {
		return listenerSocket;
	}

	public void setListenerSocket(Socket listenerSocket) {
		this.listenerSocket = listenerSocket;
	}

	public BufferedReader getListenerBufferReader() {
		return listenerStreamReader;
	}

	public void setListenerBufferReader(BufferedReader listenerBufferReader) {
		this.listenerStreamReader = listenerBufferReader;
	}
}
